<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="layui/css/layui.css">

</head>

<body>
    <div class="layui-form-item">
        <label class="layui-form-label">水仙花数</label>
        <div class="layui-input-block">
            <input type="text" id="ouShu" placeholder="请输入标题" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" onclick="get()"><i class="layui-icon layui-icon-search"></i>获取数据</button>
        </div>
    </div>
    <script src="layui/layui.js"></script>
    <script>
        // 计算100以内奇数之和，偶数之和
        function get(){
            var ouShu = "";
            for (let index = 100; index < 1000; index++) {
                var geWei = index % 10;
                var shiWei = parseInt(index/10) % 10;
                var baiWei = parseInt(index / 100);
                var num = geWei*geWei*geWei  + shiWei*shiWei*shiWei + baiWei*baiWei*baiWei;
                if(index == num){
                    ouShu+=index + ","
            
                }
            }

            ouShu = ouShu.substring(0,ouShu.length - 1);
            console.log(ouShu);

            document.getElementById("ouShu").value = ouShu;
        }
    </script>
</body>

</html>